<template>
  <div class="login-form app-form">
    <h3>登录</h3>
    <a-form :model="formState" :rules="rules">
      <a-form-item name="phone">
        <a-input placeholder="请输入手机号" v-model:value="formState.phone" />
      </a-form-item>
      <a-form-item name="pwd">
        <a-input placeholder="请输入密码" v-model:value="formState.pwd" />
      </a-form-item>
      <a-form-item>
        <CaptchaInput />
      </a-form-item>
      <a-row>
        <a-col class="tip" :span="24">
          <a-checkbox style="height: 16px">下次自动登录</a-checkbox>
          <router-link to="/login?forget=1">忘记密码</router-link>
        </a-col>

        <a-col :span="24" class="submit">
          <a-button type="primary">登录</a-button>
        </a-col>
      </a-row>
    </a-form>
  </div>
</template>

<script lang="ts" setup>
import { reactive, h } from 'vue';
import { CloseCircleFilled } from '@ant-design/icons-vue';
import CaptchaInput from './CaptchaInput.vue';

const formState = reactive({
  phone: '',
  pwd: '',
});
const rules = {
  pwd: {
    required: true,
    message: h(
      'div',
      {
        className: 'form-error-tip',
      },
      [h(CloseCircleFilled), '请输入正确密码'],
    ),
    trigger: 'blur',
  },
  phone: {
    required: true,
    message: '请输入正确的手机号',
    trigger: 'blur',
  },
};
</script>

<style lang="scss" scoped>
.login-form {
  h3 {
    margin-top: 69px !important;
  }
  :deep(.ant-input) {
    height: 52px;
    background: #f7f7f7;
    border-radius: 6px;
  }
  :deep(.ant-form-item) {
    margin-bottom: 30px;
  }
  :deep(.ant-form-item-explain) {
    bottom: -29px;
  }
  .tip {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
  }
  .submit {
    margin-bottom: 64px;
    :deep(.ant-btn) {
      width: 100%;
      height: 48px;
      box-shadow: 0px 6px 12px 0px rgba(24, 144, 255, 0.26);
      border-radius: 6px;
    }
  }
}
</style>
